﻿using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CadDotNetTools;

namespace CircleTools
{
    public static class MyCircle
    {
        /// <summary>
        /// 圆
        /// </summary>
        /// <param name="doc">Document</param>
        public static void Circles(this Document doc)
        {
            var db = doc.Database;
            var ed = doc.Editor;
            Point3d center = new Point3d();
            double radius = 0;
            PromptPointResult ppr = ed.GetPoint("\n 请指定圆心");
            if (ppr.Status == PromptStatus.OK)
            {
                center = ppr.Value;
            }
            #region
            //PromptDistanceOptions pdo = new PromptDistanceOptions("\n 请指定圆上的一点：");
            //pdo.BasePoint = center;
            //pdo.UseBasePoint = true;
            //pdo.UseDashedLine = true;
            //PromptDoubleResult pdr = ed.GetDistance(pdo);
            //if (pdr.Status == PromptStatus.OK)
            //{
            //    radius = pdr.Value;
            //}
            //db.AddCircleToModelSpace(center,radius);
            #endregion
            CircleJig jCircle = new CircleJig(center);

            //方法1：
            //PromptPointResult pr = (PromptPointResult)ed.Drag(jCircle);  //进入sampler
            //if (pr.Status == PromptStatus.OK)
            //{
            //    Point3d pt = pr.Value;
            //    db.AddCircleToModelSpace(center, pt.GetDistanceBetweenTwoPoint(center));
            //}



            //方法2：
            PromptResult pr = ed.Drag(jCircle);
            if (pr.Status == PromptStatus.OK)
            {
                db.AddEntityToModelSpace(jCircle.GetEntity());
            }
        }
    }
}
